<xsl:template match='/'>
\documentclass{article}
\usepackage[dutch]{babel}
\usepackage[latin1]{inputenc}
\usepackage{array}
\usepackage[a4paper,tmargin=0.5cm,lmargin=0.5cm,landscape]{geometry}
\setlength{\textwidth}{28.5cm}
\setlength{\textheight}{19cm}
\setlength\arrayrulewidth{.1pt}
\newcommand{\doos}[3]{
\renewcommand{\arraystretch}{0.75}
  \begin{tabular}{lr}
      \scriptsize #1 &amp; \scriptsize #2 \\ 
      \multicolumn{2}{c}{#3} 
  \end{tabular}
}
\setlength\tabcolsep{0.07cm}
\pagestyle{empty}
\begin{document}
\noindent
\subsection*{Sint-Ritacollege <xsl:value-of select='//rapport[1]/@jaar' />-<xsl:value-of select='//rapport[1]/@jaar + 1' /> \hfill Overzicht cijfers <xsl:value-of select='//rapport[1]/leerling/klas' /> \hfill Semesterrapport 2}
\begin{tabular}{|l||<xsl:for-each select="//rapport[1]/vakken/*">c|</xsl:for-each>|c|}
\hline
&amp;<xsl:for-each select="//rapport[1]/vakken/*"><xsl:value-of select="name()" />&amp;</xsl:for-each>TOT\\
\hline
\hline
<xsl:for-each select="//rapport"><xsl:call-template name="vakcijfers" /></xsl:for-each>
\hline
\hline
Gemiddelde &amp; 
<xsl:for-each select="//rapport[1]/vakken/*">
  <xsl:call-template name="gemiddeldecijfers" />
</xsl:for-each>
<xsl:value-of select="//rapport[1]/totaal/tottot2gem" /> \\
\hline
\end{tabular}
\end{document}
</xsl:template>

<xsl:template name="vakcijfers">
   <xsl:value-of select="leerling/voornaam" />&#160;<xsl:value-of select="leerling/achternaam" /> &amp;
   <xsl:for-each select="vakken/*">\doos {<xsl:value-of select="dw2" />} {<xsl:value-of select="ex2" />}{<xsl:value-of select="tot2" />}&amp;</xsl:for-each><xsl:value-of select="totaal/tottot2" />\\
   \hline
</xsl:template>

<xsl:template name="gemiddeldecijfers">
   \doos {<xsl:value-of select="dw2gem" />} {<xsl:value-of select="ex2gem" />}{<xsl:value-of select="tot2gem" />}&amp;
</xsl:template>
